﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<link href="../../Scripts/selfCalender/css/selfcalender_css.css" rel="stylesheet"
    type="text/css" />

<script src="../../Scripts/selfCalender/selfcalender.js" type="text/javascript"></script>

<script type="text/javascript">
    var calender = null;
    $(function() {
        var options = {
            day_click: doNote,
            switch_click: outstandDate
        };
        calender = $("#calender");
        $(calender).selfcalender(options);
        outstandDate();
    })

    function doNote(dateValue) {
        $.ajax({
            type: "POST",
            url: "/Calender/ShowNote",
            data: { "date": dateValue },
            success: function(data) {
                $("#workarea_note").html(data);
            }
        })
    }

    function outstandDate() {

        var year = $(calender).current_year();
        var month = $(calender).current_month();
        var dayCount = $(calender).current_days();

        //        var day = $(calender).first_day() - 1;
        $.ajax({
            type: "POST",
            url: "/Calender/GetOutstandDate",
            data: { "year": year, "month": month, "dayCount": dayCount },
            success: function(data) {
                if (data != "FAIL") {
                    $(calender).refresh_calender();
                    var dategrup = new Array();
                    dategrup = data.split('-');
                    var unconfirm = dategrup[0].split(';');
                    var day_date = $("#calender").children(".day_calendar").children().children(".day_date");

                    for (var dateindex = 0; dateindex < unconfirm.length - 1; dateindex++) {
                        $("span.show_" + month + ":eq(" + (parseInt(unconfirm[dateindex]) - 1) + ")").addClass("ui_unconfirm");
                        if ($(day_date).html() == unconfirm[dateindex])
                            $(day_date).addClass("day_ui_unconfirm");
                    }

                    var hurry = dategrup[1].split(';');
                    for (dateindex = 0; dateindex < hurry.length - 1; dateindex++) {
                        $("span.show_" + month + ":eq(" + (parseInt(hurry[dateindex]) - 1) + ")").addClass("ui_hurry");
                        if ($(day_date).html() == hurry[dateindex])
                            $(day_date).addClass("day_ui_hurry");
                    }

                    var noted = dategrup[2].split(';');
                    for (dateindex = 0; dateindex < noted.length - 1; dateindex++) {
                        $("span.show_" + month + ":eq(" + (parseInt(noted[dateindex]) - 1) + ")").addClass("ui_noted");
                        if ($(day_date).html() == noted[dateindex])
                            $(day_date).addClass("day_ui_noted");
                    }
                }
            }
        });
    }

    //    function addnoteTab(date) {
    //        var dateValue = date;
    //        $(glo_tab).addtab('node', '记事本');

    //        $.ajax({
    //            type: "POST",
    //            url: "/Calender/ShowNote",
    //            data: { "date": dateValue },
    //            success: function(data) {
    //                $("#workarea-node").html(data);
    //            }
    //        })
    //    }
</script>
